\subsection{ctapi.c File Reference}
\label{ctapi_8c}\index{ctapi.c@{ctapi.c}}


Virtual CT-\/API library.  


{\ttfamily \#include $<$unistd.h$>$}\par
{\ttfamily \#include $<$stdio.h$>$}\par
{\ttfamily \#include $<$stdlib.h$>$}\par
{\ttfamily \#include $<$string.h$>$}\par
{\ttfamily \#include $<$sys/types.h$>$}\par
{\ttfamily \#include $<$ctapi.h$>$}\par
{\ttfamily \#include $<$main.h$>$}\par
{\ttfamily \#include $<$types.h$>$}\par
{\ttfamily \#include $<$sw.h$>$}\par
\subsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
{\bf IS8} {\bf CT\_\-forkIcc} (void)
\item 
{\bf IS8} {\bf CT\_\-stopIcc} (void)
\item 
{\bf IS8} {\bf CT\_\-ifdCmdResetCT} ({\bf IU16} lenc, {\bf IU8} $\ast$command, {\bf IU16} $\ast$lenr, {\bf IU8} $\ast${\bf response})
\item 
{\bf IS8} {\bf CT\_\-ifdCmdRequestICC} ({\bf IU16} lenc, {\bf IU8} $\ast$command, {\bf IU16} $\ast$lenr, {\bf IU8} $\ast${\bf response})
\item 
{\bf IS8} {\bf CT\_\-ifdCmdGetStatus} ({\bf IU16} lenc, {\bf IU8} $\ast$command, {\bf IU16} $\ast$lenr, {\bf IU8} $\ast${\bf response})
\item 
{\bf IS8} {\bf CT\_\-ifdCmdEjectICC} ({\bf IU16} lenc, {\bf IU8} $\ast$command, {\bf IU16} $\ast$lenr, {\bf IU8} $\ast${\bf response})
\item 
{\bf IS8} {\bf CT\_\-ifdCmdEepromFile} ({\bf IU16} lenc, {\bf IU8} $\ast$command, {\bf IU16} $\ast$lenr, {\bf IU8} $\ast${\bf response})
\begin{DoxyCompactList}\small\item\em Parses EEPROM FILE command. \item\end{DoxyCompactList}\item 
{\bf IS8} {\bf CT\_\-ifdCmd} ({\bf IU16} lenc, {\bf IU8} $\ast$command, {\bf IU16} $\ast$lenr, {\bf IU8} $\ast${\bf response})
\item 
int {\bf CT\_\-t0} ({\bf IU16} lenc, {\bf IU8} $\ast$command, {\bf IU16} $\ast$lenr, {\bf IU8} $\ast${\bf response})
\item 
{\bf IS8} {\bf CT\_\-iccCmd} ({\bf IU8} $\ast$dad, {\bf IU8} $\ast$sad, {\bf IU16} lenc, {\bf IU8} $\ast$command, {\bf IU16} $\ast$lenr, {\bf IU8} $\ast${\bf response})
\item 
{\bf IS8} {\bf CT\_\-init} ({\bf IU16} ctn, {\bf IU16} pn)
\item 
{\bf IS8} {\bf CT\_\-data} ({\bf IU16} ctn, {\bf IU8} $\ast$dad, {\bf IU8} $\ast$sad, {\bf IU16} lenc, {\bf IU8} $\ast$command, {\bf IU16} $\ast$lenr, {\bf IU8} $\ast${\bf response})
\item 
{\bf IS8} {\bf CT\_\-close} ({\bf IU16} ctn)
\end{DoxyCompactItemize}
\subsubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
{\bf IS32} {\bf cthandle} = -\/1
\item 
int {\bf fd\_\-fromCard} [2]
\item 
int {\bf fd\_\-toCard} [2]
\item 
pid\_\-t {\bf pidVirtuaCard} = 0
\item 
int {\bf loadEepromFile} = FALSE
\item 
int {\bf saveEepromFile} = FALSE
\item 
char {\bf eepromFile} [256]
\item 
int {\bf fdEepromFile}
\item 
char {\bf atr} [32]
\item 
int {\bf atrlen} = 0
\end{DoxyCompactItemize}


\subsubsection{Detailed Description}
Virtual CT-\/API library. \begin{DoxyParagraph}{Id:}
\doxyref{ctapi.c}{p.}{ctapi_8c},v 1.4 2002/12/24 13:29:57 m Exp 
\end{DoxyParagraph}


\subsubsection{Function Documentation}
\index{ctapi.c@{ctapi.c}!CT\_\-close@{CT\_\-close}}
\index{CT\_\-close@{CT\_\-close}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-close}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-close (
\begin{DoxyParamCaption}
\item[{{\bf IU16}}]{ ctn}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_a67b4abae7b7747f70770a4cd0a96ae94}


References CT\_\-stopIcc(), CTAPI\_\-RV\_\-OK, and cthandle.

\index{ctapi.c@{ctapi.c}!CT\_\-data@{CT\_\-data}}
\index{CT\_\-data@{CT\_\-data}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-data}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-data (
\begin{DoxyParamCaption}
\item[{{\bf IU16}}]{ ctn, }
\item[{{\bf IU8} $\ast$}]{ dad, }
\item[{{\bf IU8} $\ast$}]{ sad, }
\item[{{\bf IU16}}]{ lenc, }
\item[{{\bf IU8} $\ast$}]{ command, }
\item[{{\bf IU16} $\ast$}]{ lenr, }
\item[{{\bf IU8} $\ast$}]{ response}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_a13d6bd18636dbb982be987e695a4b747}


References CT\_\-iccCmd(), CT\_\-ifdCmd(), CTAPI\_\-AD\_\-CT, CTAPI\_\-AD\_\-HOST, CTAPI\_\-AD\_\-ICC1, and cthandle.

\index{ctapi.c@{ctapi.c}!CT\_\-forkIcc@{CT\_\-forkIcc}}
\index{CT\_\-forkIcc@{CT\_\-forkIcc}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-forkIcc}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-forkIcc (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_a98caba510268b73db36f0782254f733f}


References atr, atrlen, CT\_\-stopIcc(), CTAPI\_\-RV\_\-OK, fd\_\-fromCard, fd\_\-toCard, and pidVirtuaCard.



Referenced by CT\_\-ifdCmdRequestICC(), and CT\_\-ifdCmdResetCT().

\index{ctapi.c@{ctapi.c}!CT\_\-iccCmd@{CT\_\-iccCmd}}
\index{CT\_\-iccCmd@{CT\_\-iccCmd}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-iccCmd}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-iccCmd (
\begin{DoxyParamCaption}
\item[{{\bf IU8} $\ast$}]{ dad, }
\item[{{\bf IU8} $\ast$}]{ sad, }
\item[{{\bf IU16}}]{ lenc, }
\item[{{\bf IU8} $\ast$}]{ command, }
\item[{{\bf IU16} $\ast$}]{ lenr, }
\item[{{\bf IU8} $\ast$}]{ response}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_a6e8efacf1d6a9c2baec39122663eb693}


References CT\_\-t0(), and pidVirtuaCard.



Referenced by CT\_\-data().

\index{ctapi.c@{ctapi.c}!CT\_\-ifdCmd@{CT\_\-ifdCmd}}
\index{CT\_\-ifdCmd@{CT\_\-ifdCmd}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-ifdCmd}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-ifdCmd (
\begin{DoxyParamCaption}
\item[{{\bf IU16}}]{ lenc, }
\item[{{\bf IU8} $\ast$}]{ command, }
\item[{{\bf IU16} $\ast$}]{ lenr, }
\item[{{\bf IU8} $\ast$}]{ response}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_a2721d2def6d1963a8e2ae2c030e58c7a}


References CT\_\-ifdCmdEepromFile(), CT\_\-ifdCmdEjectICC(), CT\_\-ifdCmdGetStatus(), CT\_\-ifdCmdRequestICC(), CT\_\-ifdCmdResetCT(), CTAPI\_\-INS\_\-EEPROM, CTAPI\_\-INS\_\-EJECT\_\-ICC, CTAPI\_\-INS\_\-GET\_\-STATUS, CTAPI\_\-INS\_\-REQUEST\_\-ICC, and CTAPI\_\-INS\_\-RESET\_\-CT.



Referenced by CT\_\-data().

\index{ctapi.c@{ctapi.c}!CT\_\-ifdCmdEepromFile@{CT\_\-ifdCmdEepromFile}}
\index{CT\_\-ifdCmdEepromFile@{CT\_\-ifdCmdEepromFile}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-ifdCmdEepromFile}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-ifdCmdEepromFile (
\begin{DoxyParamCaption}
\item[{{\bf IU16}}]{ lenc, }
\item[{{\bf IU8} $\ast$}]{ command, }
\item[{{\bf IU16} $\ast$}]{ lenr, }
\item[{{\bf IU8} $\ast$}]{ response}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_a3f9effa1af0997b57f4fcf5f5ca6b063}


Parses EEPROM FILE command. 


\begin{DoxyItemize}
\item CLA: '20'
\item INS: 'E0'
\item P1:
\begin{DoxyItemize}
\item bit 1: Save EEPROM to file at eject or reset.
\item bit 2: Load EEPROM from file at reset.
\end{DoxyItemize}
\item P2: RFU
\item Lc: Length of file name
\item Data: File name (possibly including path) without null-\/termination 
\end{DoxyItemize}

References eepromFile, loadEepromFile, and saveEepromFile.



Referenced by CT\_\-ifdCmd().

\index{ctapi.c@{ctapi.c}!CT\_\-ifdCmdEjectICC@{CT\_\-ifdCmdEjectICC}}
\index{CT\_\-ifdCmdEjectICC@{CT\_\-ifdCmdEjectICC}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-ifdCmdEjectICC}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-ifdCmdEjectICC (
\begin{DoxyParamCaption}
\item[{{\bf IU16}}]{ lenc, }
\item[{{\bf IU8} $\ast$}]{ command, }
\item[{{\bf IU16} $\ast$}]{ lenr, }
\item[{{\bf IU8} $\ast$}]{ response}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_a101877b1f26262069c4bf34174f28004}


References CT\_\-stopIcc().



Referenced by CT\_\-ifdCmd().

\index{ctapi.c@{ctapi.c}!CT\_\-ifdCmdGetStatus@{CT\_\-ifdCmdGetStatus}}
\index{CT\_\-ifdCmdGetStatus@{CT\_\-ifdCmdGetStatus}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-ifdCmdGetStatus}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-ifdCmdGetStatus (
\begin{DoxyParamCaption}
\item[{{\bf IU16}}]{ lenc, }
\item[{{\bf IU8} $\ast$}]{ command, }
\item[{{\bf IU16} $\ast$}]{ lenr, }
\item[{{\bf IU8} $\ast$}]{ response}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_ab333926cd2df6b77b6a911881e184af7}


References pidVirtuaCard.



Referenced by CT\_\-ifdCmd().

\index{ctapi.c@{ctapi.c}!CT\_\-ifdCmdRequestICC@{CT\_\-ifdCmdRequestICC}}
\index{CT\_\-ifdCmdRequestICC@{CT\_\-ifdCmdRequestICC}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-ifdCmdRequestICC}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-ifdCmdRequestICC (
\begin{DoxyParamCaption}
\item[{{\bf IU16}}]{ lenc, }
\item[{{\bf IU8} $\ast$}]{ command, }
\item[{{\bf IU16} $\ast$}]{ lenr, }
\item[{{\bf IU8} $\ast$}]{ response}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_aa40ac7ec66071913781ff96226845110}


References atr, atrlen, CT\_\-forkIcc(), and CTAPI\_\-RV\_\-OK.



Referenced by CT\_\-ifdCmd().

\index{ctapi.c@{ctapi.c}!CT\_\-ifdCmdResetCT@{CT\_\-ifdCmdResetCT}}
\index{CT\_\-ifdCmdResetCT@{CT\_\-ifdCmdResetCT}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-ifdCmdResetCT}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-ifdCmdResetCT (
\begin{DoxyParamCaption}
\item[{{\bf IU16}}]{ lenc, }
\item[{{\bf IU8} $\ast$}]{ command, }
\item[{{\bf IU16} $\ast$}]{ lenr, }
\item[{{\bf IU8} $\ast$}]{ response}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_ac4eb9ba08eb13cae90eb9c989f578abe}


References atr, atrlen, CT\_\-forkIcc(), CT\_\-stopIcc(), and CTAPI\_\-RV\_\-OK.



Referenced by CT\_\-ifdCmd().

\index{ctapi.c@{ctapi.c}!CT\_\-init@{CT\_\-init}}
\index{CT\_\-init@{CT\_\-init}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-init}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-init (
\begin{DoxyParamCaption}
\item[{{\bf IU16}}]{ ctn, }
\item[{{\bf IU16}}]{ pn}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_a1e1238e91c7a0daad5d29c3a5b96c59c}


References CTAPI\_\-PORT, cthandle, and pidVirtuaCard.

\index{ctapi.c@{ctapi.c}!CT\_\-stopIcc@{CT\_\-stopIcc}}
\index{CT\_\-stopIcc@{CT\_\-stopIcc}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-stopIcc}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS8} CT\_\-stopIcc (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_a7db4e593d403b5155420634f7bdd9ba5}


References fd\_\-toCard, and pidVirtuaCard.



Referenced by CT\_\-close(), CT\_\-forkIcc(), CT\_\-ifdCmdEjectICC(), and CT\_\-ifdCmdResetCT().

\index{ctapi.c@{ctapi.c}!CT\_\-t0@{CT\_\-t0}}
\index{CT\_\-t0@{CT\_\-t0}!ctapi.c@{ctapi.c}}
\paragraph[{CT\_\-t0}]{\setlength{\rightskip}{0pt plus 5cm}int CT\_\-t0 (
\begin{DoxyParamCaption}
\item[{{\bf IU16}}]{ lenc, }
\item[{{\bf IU8} $\ast$}]{ command, }
\item[{{\bf IU16} $\ast$}]{ lenr, }
\item[{{\bf IU8} $\ast$}]{ response}
\end{DoxyParamCaption}
)}\hfill\label{ctapi_8c_a52374767ffb32583eed4dab3cf189461}


References CTAPI\_\-RV\_\-ERR\_\-TRANS, CTAPI\_\-RV\_\-OK, fd\_\-fromCard, fd\_\-toCard, and TRUE.



Referenced by CT\_\-iccCmd().



\subsubsection{Variable Documentation}
\index{ctapi.c@{ctapi.c}!atr@{atr}}
\index{atr@{atr}!ctapi.c@{ctapi.c}}
\paragraph[{atr}]{\setlength{\rightskip}{0pt plus 5cm}char {\bf atr}[32]}\hfill\label{ctapi_8c_a8780a5f71b6a8c4fa48ce4bea7d03794}


Referenced by CT\_\-forkIcc(), CT\_\-ifdCmdRequestICC(), and CT\_\-ifdCmdResetCT().

\index{ctapi.c@{ctapi.c}!atrlen@{atrlen}}
\index{atrlen@{atrlen}!ctapi.c@{ctapi.c}}
\paragraph[{atrlen}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf atrlen} = 0}\hfill\label{ctapi_8c_a11c1dcf61d5a36a1219f50a568844751}


Referenced by CT\_\-forkIcc(), CT\_\-ifdCmdRequestICC(), and CT\_\-ifdCmdResetCT().

\index{ctapi.c@{ctapi.c}!cthandle@{cthandle}}
\index{cthandle@{cthandle}!ctapi.c@{ctapi.c}}
\paragraph[{cthandle}]{\setlength{\rightskip}{0pt plus 5cm}{\bf IS32} {\bf cthandle} = -\/1}\hfill\label{ctapi_8c_a826a7d1cd5865c5c41ddc8ebf86fd12c}


Referenced by CT\_\-close(), CT\_\-data(), and CT\_\-init().

\index{ctapi.c@{ctapi.c}!eepromFile@{eepromFile}}
\index{eepromFile@{eepromFile}!ctapi.c@{ctapi.c}}
\paragraph[{eepromFile}]{\setlength{\rightskip}{0pt plus 5cm}char {\bf eepromFile}[256]}\hfill\label{ctapi_8c_a91595ea16849581ca08f6b850bccf4d6}


Referenced by CT\_\-ifdCmdEepromFile(), hal\_\-init(), and hal\_\-io\_\-recByteT0().

\index{ctapi.c@{ctapi.c}!fd\_\-fromCard@{fd\_\-fromCard}}
\index{fd\_\-fromCard@{fd\_\-fromCard}!ctapi.c@{ctapi.c}}
\paragraph[{fd\_\-fromCard}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf fd\_\-fromCard}[2]}\hfill\label{ctapi_8c_a7290409d96c589b579b6b52d0c1f85d1}


Referenced by CT\_\-forkIcc(), CT\_\-t0(), hal\_\-init(), hal\_\-io\_\-recByteT0(), and hal\_\-io\_\-sendByteT0().

\index{ctapi.c@{ctapi.c}!fd\_\-toCard@{fd\_\-toCard}}
\index{fd\_\-toCard@{fd\_\-toCard}!ctapi.c@{ctapi.c}}
\paragraph[{fd\_\-toCard}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf fd\_\-toCard}[2]}\hfill\label{ctapi_8c_a748c2a8296faf59f5e7ef53b672f0122}


Referenced by CT\_\-forkIcc(), CT\_\-stopIcc(), CT\_\-t0(), and hal\_\-io\_\-recByteT0().

\index{ctapi.c@{ctapi.c}!fdEepromFile@{fdEepromFile}}
\index{fdEepromFile@{fdEepromFile}!ctapi.c@{ctapi.c}}
\paragraph[{fdEepromFile}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf fdEepromFile}}\hfill\label{ctapi_8c_a5f7757661982a05e978dbb4cd0f70bc1}


Referenced by hal\_\-init(), and hal\_\-io\_\-recByteT0().

\index{ctapi.c@{ctapi.c}!loadEepromFile@{loadEepromFile}}
\index{loadEepromFile@{loadEepromFile}!ctapi.c@{ctapi.c}}
\paragraph[{loadEepromFile}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf loadEepromFile} = FALSE}\hfill\label{ctapi_8c_a59c083ae3f67fa2dac32718136d60e96}


Referenced by CT\_\-ifdCmdEepromFile(), and hal\_\-init().

\index{ctapi.c@{ctapi.c}!pidVirtuaCard@{pidVirtuaCard}}
\index{pidVirtuaCard@{pidVirtuaCard}!ctapi.c@{ctapi.c}}
\paragraph[{pidVirtuaCard}]{\setlength{\rightskip}{0pt plus 5cm}pid\_\-t {\bf pidVirtuaCard} = 0}\hfill\label{ctapi_8c_af418387f735ecbccf345059e663eec70}


Referenced by CT\_\-forkIcc(), CT\_\-iccCmd(), CT\_\-ifdCmdGetStatus(), CT\_\-init(), and CT\_\-stopIcc().

\index{ctapi.c@{ctapi.c}!saveEepromFile@{saveEepromFile}}
\index{saveEepromFile@{saveEepromFile}!ctapi.c@{ctapi.c}}
\paragraph[{saveEepromFile}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf saveEepromFile} = FALSE}\hfill\label{ctapi_8c_a4792ff850c85ef5072714ffd0a56ef1d}


Referenced by CT\_\-ifdCmdEepromFile(), and hal\_\-io\_\-recByteT0().

